<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%@ page import="donnees.Commande"%>
<%@ page import="donnees.Client"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.HashMap"%>
    
<jsp:include page="header.jsp" />

<div id="content">	
	<div id="colOne">
		<div class="commande">
		<h2>Historique commandes</h2>
		
		<%	if (request.getAttribute("commandes") != null) { 	%>
			<% ArrayList<Commande> commandes = (ArrayList<Commande>) request.getAttribute("commandes"); %>
			<% HashMap<Integer, ArrayList<String>> lignesCommande = (HashMap<Integer, ArrayList<String>>) request.getAttribute("lignescommandes"); %>
			
			<%
			for (Commande cmd : commandes) {
			%>
		
		<table class="panier">			
		  <tr>
		      <th> Date </th>
		      <th> Livraison </th>
		      <th> Prix total </th>		  
  		  </tr>
		  <tr>
              <td> <%= cmd.getDateCommande() %>  </td>
              <td> <%= cmd.getDateLivraison() %> </td>
              <td> <%= cmd.getPrixTotal() %> € </td>                    
          </tr>
		 </table>
		 
		 <ul> 
		  		<% for (String ligne : lignesCommande.get(cmd.getIdCommande())) { %>	         
		  	<li> <%= ligne %> </li>       		 
		  		<% } %> 
		  </ul>
		  <div class="separ"></div>   
		  	<% } %>
		  <% } %>          
               	
		</div>
	</div>
	<div id="colTwo">
		
		<h2><a href="?cmd=connexion&logout=true">Déconnexion</a></h2>
	
		<h2>Adresse livraison</h2>
		<%	if (request.getAttribute("client") != null) { 	%>
			<% Client client = (Client) request.getAttribute("client"); %>
		<p><%= client.getPrenom() %> <%= client.getNom() %><br />
		<%= client.getNumero() %> <%= client.getRue() %><br />
		<%= client.getCp() %> <%= client.getVille() %>
		</p>
		<% } %>
		<h2>Modifier </h2>
		<%
			if ((request.getAttribute("erreur_modif") != null)) {
		%>
		<p>
			<b>Erreur : <%=request.getAttribute("erreur_modif")%></b>
		</p>
		<%
			}
		%>		
		<form id="modif" action="?cmd=historique" method="post">
			<label>prénom</label><input type="text" name="modprenom" value="<%=request.getAttribute("modprenom")%>" /><br />
			<label>nom</label><input type="text" name="modnom" value="<%=request.getAttribute("modnom")%>" /><br />
			<label>numéro</label><input type="text" name="modnumero" value="<%=request.getAttribute("modnumero")%>" /><br />
			<label>adresse</label><input type="text" name="modadresse" value="<%=request.getAttribute("modadresse")%>" /><br />
			<label>cp</label><input type="text" name="modcodepostal" value="<%=request.getAttribute("modcodepostal")%>" /><br />
			<label>ville</label><input type="text" name="modville" value="<%=request.getAttribute("modville")%>" /><br />
			<input type="hidden" name="modifier" value="ok" />
			<input type="submit" value="modifier" />
		</form>
	</div>
	<div style="clear: both;">&nbsp;</div>
</div>

<jsp:include page="footer.jsp" />